﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;

namespace PeisongWeb
{
    public partial class buyer_deviateCollect : buyerPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (hasPermission("BC", 1))
                {
                    rptBind();
                }
                else
                {
                    Library.Script.ClientMsgUrl("没有权限！", "buyer_index.html");
                    return;
                }
            }
        }

        void rptBind()
        {
            StringBuilder where = new StringBuilder();
            where.AppendFormat("initQuantity <> quantity and companyId={0}",logic.customer.getCompanyId());
            if (txt_orderNo.Value.Trim() != "")
                where.AppendFormat(" and orderNo='{0}'",txt_orderNo.Value.Trim());
            if (ext_StartInputDt.SelectedDate != DateTime.MinValue)
                where.AppendFormat(" and datediff(day,[inputDt],'{0}')<=0", ext_StartInputDt.Value.ToString());
            if (ext_EndInputDt.SelectedDate != DateTime.MinValue)
                where.AppendFormat(" and datediff(day,[inputDt],'{0}')>=0", ext_EndInputDt.Value.ToString());
            DataSet ds = logic.orderItem.select(where.ToString(), "oiid desc", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex);
            AspNetPager1.RecordCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            rpt_list.DataSource = ds.Tables[1];
            rpt_list.DataBind();
        }
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            rptBind();
        }
        protected void btn_select_Click(object sender, EventArgs e)
        {
            rptBind();
        }
    }
}
